﻿using System;

using Sunyi.Project.WebPoint.DataContract;
using Sunyi.Project.WebPoint.ServiceContract;
using System.Collections.ObjectModel;

namespace Sunyi.Project.WebPoint.ServiceAccess
{
    public class SystemInfoServiceProxy : WebPointServiceProxy<ISystemInfoService>, ISystemInfoService
    {
        protected override string ClientEndPointName
        {
            get
            {
                return "SystemInfoService";
            }
        }

        public SystemInfo GetSystemInfo(Guid systemId)
        {
            SystemInfo result = null;
            var channel = this.CreateChannel();

            var action = new Action(delegate { result = channel.GetSystemInfo(systemId); });

            this.Invoke(channel, action);
            return result;
        }

        public SystemInfo GetSystemInfo(string systemName)
        {
            SystemInfo result = null;
            var channel = this.CreateChannel();

            var action = new Action(delegate { result = channel.GetSystemInfo(systemName); });

            this.Invoke(channel, action);
            return result;
        }

        public Collection<SystemInfo> GetAllSystemInfo()
        {
            Collection<SystemInfo> result = null;
            var channel = this.CreateChannel();

            var action = new Action(delegate { result = channel.GetAllSystemInfo(); });

            this.Invoke(channel, action);
            return result;
        }

        public void UpdateSystemInfo(SystemInfo systemInfo, Collection<Role> roles)
        {
            var channel = this.CreateChannel();

            var action = new Action(delegate { channel.UpdateSystemInfo(systemInfo,roles); });

            this.Invoke(channel, action);
        }
    }
}
